<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<base href="__ROOT__" />
<link rel="stylesheet" type="text/css" href="__RES__images/metinfo.css" />
<script type="text/javascript" src="__RES__ckeditor/ckeditor.js"></script>
<link rel="stylesheet" href="__RES__kindeditor/themes/default/default.css" />
<script charset="utf-8" src="__RES__kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="__RES__kindeditor/lang/zh_CN.js"></script>
<script>
			var editor;
			KindEditor.ready(function(K) {
				editor = K.create('textarea[name="content"]', {
					allowFileManager : true
				});
				
			});
</script>
<script charset="utf-8" src="__RES__js/jQuery1.7.2.js"></script>
<script>
$(document).ready(function(e) {
    $("form").submit(function(){			
		var name=$("#name").val();		
		if(name==''){
			$("#name").next().html('<font>*分类名称不能为空</font>');			
			return false;
			}		
		});
		
	//增加分类 
	$(".input select").live("change",function(){
		var obj=$(this);
		var size=$(this).get(0).selectedIndex;
		var parentid=$(this).val();
		$("#parentid").val(parentid);
		var catid=$("#catid").val();
		$.ajax({
			type:"post",
			url:"index.php/admin/category/ajax",
			data:{
				parentid:parentid
				},
			dataType:"json",
			success: function(json){
				
				obj.nextAll().remove();
				if(size==0){
					return false;
					}
				if(json==null){
					return false;
				}
				var str='';
				str+='<select name="category">';
				str+='<option value="'+parentid+'">上一级</option>';
				for(var i=0;i<json.length;i++){
					
					if(catid==json[i].catid){
						str+='<option disabled="disabled" value="'+json[i].catid+'">'+json[i].name+'</option>';
						}else{
							str+='<option value="'+json[i].catid+'">'+json[i].name+'</option>';
							}
					
				}  
				str+='</select>';
				obj.after(str);
			}
			});
		
		
		});	
});
</script>

<link rel="stylesheet" type="text/css" href="__RES__css/bootstrap.css" />
<link rel="stylesheet" type="text/css" href="__RES__css/bootstrap-responsive.css" />
<link rel="stylesheet" type="text/css" href="__RES__css/style.css" />
<style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


</style>
</head>

<body>

	<div class="metinfotop">
	<div class="position">简体中文：分类管理 > <a href="javascript:void(0)">{$lang}分类</a></div>

	</div>
	<div class="clear"></div>


<div class="stat_list">
	<ul>
		<li class="now"><a href="index.php/admin/category/save" title="{$lang}分类">{$lang}分类</a></li>
		<li><a href="index.php/admin/category/list" title="分类列表">分类列表</a></li>
	</ul>
</div>
<form method="post" name="myform" action="index.php/admin/category/save/id/{$one.catid}" target="_self">
<table class="table table-bordered table-hover definewidth m10">
<input name="catid" id="catid" type="hidden" value="{$one.catid}" />
    <tr>
        <td width="10%" class="tableleft">分类名称</td>
        <td><input type="text" id="name" name="name" value="{$one.name}"/><span></span></td>
    </tr>
    
    <tr style="display:none;"> 
        <td width="10%" class="tableleft">PARENTID</td>
        <td class="input"><input name="parentid" id="parentid" type="text" class="text" value="{$one.parentid}" /><span style="color:#F00"></span></td>
       
    </tr>
     
    <tr>
        <td class="tableleft">请选择分类</td>
        <td class="input">
        
        <if condition="$one.catid eq '' ">
       		<select name="category" class="select">
                <option value="0">顶级分类</option>
                <foreach name="list" item="vo" key="k" >
                <option value="{$vo.catid}">{$vo.name}</option> 
                </foreach>    
          	</select> 
        <else />
        	<foreach name="retult" item="vvo" key="k1" >
                <select name="category" class="select">
                    <option value="{$vvo.0.parentid}">上一级分类</option>
                    <foreach name="vvo" item="v" key="k2" >
                    	<option <if condition="$k1 eq $v['catid'] and $one.catid neq $v['catid'] "> selected="selected" </if> <if condition="$one.catid eq $v['catid'] "> disabled="disabled" </if>  value="{$v.catid}">
                        {$v.name}
                        </option> 
                    </foreach>    
                </select> 
            </foreach>    
        </if>
        
        
        </td>

    </tr>

    <tr>
        <td class="tableleft"></td>
        <td>
            <button type="submit" class="btn btn-primary" >保存</button> &nbsp;&nbsp;<button type="submit" class="btn btn-success" name="backid" id="backid">返回列表</button>
        </td>
    </tr>
</table>
</form>

</body>
</html>
<script>
    $(function () {       
		$('#backid').click(function(){
				window.location.href="index.php/admin/category/list";
		 });

    });
</script>